#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>

#define MAX_DATA_SIZE 5

int main(){
	char randomCharFormData[MAX_DATA_SIZE];
	pid_t subProcessID;
	int file_pipes[2], dataLength;

	if(pipe(file_pipes) == 0)
	{
		//printf("\nPipe Creation Success!\n");
	}
	else
	{
		printf("\nPipe Creation Error!\n");
		exit(1);
	}

	if((subProcessID = fork()) == -1)
	{
		printf("\nSub Process Creation Error!\n");
	}
	else if(subProcessID == 0)
	{
		while(1)
		{
			dataLength = read(file_pipes[0], randomCharFormData, MAX_DATA_SIZE);
			printf("\nRead bytes: %d Content: %s", dataLength, randomCharFormData);
		}
		exit(0);
	}

	while(1)
	{
		strcpy(randomCharFormData, "1234567890"); 
		write(file_pipes[1], randomCharFormData, MAX_DATA_SIZE);
	}
}
